#include <stdio.h>
#include <stdbool.h>
#include <malloc.h>

#define SEQ_SIZE 1001

typedef int Element;
typedef struct STACK Stack;
struct STACK{
	Element elm;	
	Stack * next;
	int count;
};

int stk_size=1,seq_size,chk_num;

Stack * initStack();
void destroyStack(Stack*);
_Bool push(Stack *,Element);
_Bool pop(Stack*,Element*);
_Bool chk_seq(Stack*,Element*,int);

int main(void){
	int M,N,K;
	scanf("%d %d %d",&M,&N,&K);
	stk_size=M;
	seq_size =N;
	chk_num =K;

	Element seq_buf[SEQ_SIZE];
	_Bool 	chk_result[SEQ_SIZE];
	Stack *stk;

	for(int i=0;i<chk_num;i++){
		//----- init
		stk=initStack();
		//
		for(int j=0;j<seq_size;j++){
			scanf("%d",&seq_buf[j]);
		}
		//	check
		chk_result[i]=chk_seq(stk,seq_buf,seq_size);
		//
		destroyStack(stk);
	}
	
	_Bool firstLine=true;
	for(int i=0;i<chk_num;i++){
		if( firstLine ){
			firstLine=false;
			printf("%s", chk_result[i]==true?"YES":"NO");
		}else{
			printf("%s", chk_result[i]==true?"\nYES":"\nNO");
		}
	}
	
	return 0;
}



Stack *initStack(){
	Stack *s=malloc(sizeof(Stack));
	s->next=NULL;
	s->count=0;
	return s;
}

void destroyStack(Stack *head){
	Stack *current=head->next;
	Stack *tmp;
	while ( current ){
		tmp=current->next;
		free(current);
		current=tmp;
	}
	free(head);
	return;
}

_Bool push(Stack *s,Element new_elm){
	if( s->count == stk_size )
		return false;
	s->count++;
	Stack *new_node=malloc(sizeof(Stack));
	new_node->elm=new_elm;
	new_node->next=s->next;
	s->next=new_node;
	return true;
}

_Bool pop(Stack *s,Element *elm){
	if( 0 == s->count )
		return false;
	s->count--;
	Stack *tmp=s->next;
	s->next=tmp->next;
	*elm=tmp->elm;
	free(tmp);
	return true;
}

_Bool chk_seq(Stack *head,Element *pop_seq ,int seq_size){
	Element target,current_num=1,pop_elm;
	for(int i=0;i<seq_size;i++){
		target=pop_seq[i];
		if( target >= current_num ){	//当前数字还没压入堆栈
			while( target >= current_num ){
				if( push(head,current_num++) ) continue;
				else {return false;}
			}
			pop(head,&pop_elm);
		}else{	//target < current_num 当前数字已经在堆栈中了
			if ( pop(head,&pop_elm) ){
				if ( pop_elm != target ){return false;}
				else{
					continue;	// fine , next target!
				};
			}else{return false;}	// 堆栈空 出错了
		}
	}
	return true;
}
